<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
</head>
<body>
    <div class="login">
        <form >
            <table align="center" style="margin-top: 20%">
                <tr>
                    <td><span>用户名：</span></td>
                    <td><input type="text" id="userName" name="userName"></td>
                </tr>
                <tr>
                    <td><span>密码：</span></td>
                    <td><input type="password" id="password" name="password"></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="button" value="登录" id="login">
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <span id="message" style="color:red"></span>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <script src="/js/jquery-1.9.1.min.js" type="application/javascript"></script>
    <script>
        $(function(){
            login.init();
        });
        let login = {
            init:function() {
                $('#login').click(function () {
                    login.submit();
                });
            },

            submit:function() {
                console.log("登录提交")
                $.ajax({
                    url:'/user/doLogin',
                    type:'post',
                    dataType:'json',
                    //contentType: 'application/json;charset=utf-8',
                    data:{'userName':$('#userName').val(), 'password':$('#password').val()},
                    success:function(data) {
                        console.log(data);
                        if (data.errCode == 200) {
                            window.location = "/resume/";
                        } else {
                            $('#message').text(data.message);
                        }
                    }
                });
            },
        };
    </script>
</body>
</html>